from selenium import webdriver
from selenium.webdriver.common.by import By
import time


driver = webdriver.Edge()

url = "https://www.baidu.com/"

driver.get(url)

driver.find_element(By.XPATH,"//*[text()='hao123']").click()
# 获取属性
print(driver.find_element(By.XPATH, "//*[text()='hao123']").get_attribute("href"))
time.sleep(5)
driver.quit()